package com.xinhe.web.controller;

import com.querydsl.core.QueryResults;
import com.xinhe.web.annotation.WebUsed;
import com.xinhe.web.common.Result;
import com.xinhe.web.entity.SellerShop;
import com.xinhe.web.response.SellerShopDetailView;
import com.xinhe.web.service.SellerShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@Api(value = "商家店铺", tags = {"商家店铺"})
@RestController
@RequestMapping(value = {"/sellerShop"}, produces = {"application/json;charset=UTF-8"})

public class SellerShopController {
    @Autowired
    private SellerShopService sellerShopService;

    @WebUsed
    @ApiOperation(httpMethod = "GET", value = "分页查询商家店铺")
    @RequestMapping({"/pageSellerShop"})
    public QueryResults<SellerShop> pageSellerShop(String name, int pageNum, int pageSize) {
        return sellerShopService.pageSellerShop(name,pageNum,pageSize);
    }
    @ApiOperation(httpMethod = "POST", value = "保存商家店铺")
    @RequestMapping({"/saveSellerShop"})
    public Result saveSellerShop(Long userId,String iconPath, String name, String projects, String userName, String mobile) {
        return this.sellerShopService.saveSellerShop(userId,iconPath,  name, projects, userName, mobile);
    }
    @ApiOperation(httpMethod = "POST", value = "商家店铺认证审核")
    @RequestMapping({"/saveSellerShopCheck"})
    public Result saveSellerShopCheck(Set<Long> sellerShopIds,String status,String remark) {
        return this.sellerShopService.saveSellerShopCheck(sellerShopIds,status,remark);
    }

    @ApiOperation(httpMethod = "GET", value = "删除商家店铺")
    @ApiImplicitParam(name = "sellerShopId", value = "标识", required = true)
    @RequestMapping({"/deleteSellerShop"})
    public Result deleteSellerShop(Long sellerShopId) {
        return this.sellerShopService.deleteSellerShop(sellerShopId);
    }

    @ApiOperation(httpMethod = "GET", value = "商家店铺详情")
    @ApiImplicitParam(name = "sellerShopId", value = "标识", required = true)
    @RequestMapping({"/detailSellerShop"})
    public Result<SellerShopDetailView> detailSellerShop(Long sellerShopId) {
        return this.sellerShopService.detailSellerShop(sellerShopId);
    }

    @ApiOperation(httpMethod = "GET", value = "商家店铺详情")
    @ApiImplicitParam(name = "sellerUserId", value = "标识", required = true)
    @RequestMapping({"/detailSellerShopByUserId"})
    public Result<SellerShopDetailView> detailSellerShopByUserId(Long sellerUserId) {
        return this.sellerShopService.detailSellerShopByUserId(sellerUserId);
    }

    @ApiOperation(httpMethod = "GET", value = "验证我是否有商家店铺")
    @RequestMapping({"/checkSellerShopByUserId"})
    public Result checkSellerShopByUserId() {
        return this.sellerShopService.checkSellerShopByUserId();
    }
    @ApiOperation(httpMethod = "GET", value = "商家会员")
    @RequestMapping({"/findBySellerShopMember"})
    public Result findBySellerShopMember(Long sellerUserId, String name) {
        return this.sellerShopService.findBySellerShopMember(sellerUserId, name);
    }


    @ApiOperation("商家管理交易统计")
    @PostMapping({"/findBySellerShopStatistics"})
    public Result findBySellerShopStatistics(String dateType) {
        return this.sellerShopService.findBySellerShopStatistics(dateType);
    }

    @ApiOperation("商家管理数据统计查询视图")
    @PostMapping({"/findByBranchDataStatistics"})
    public Result findByBranchDataStatistics(String dateType) {
        return this.sellerShopService.findByBranchDataStatistics(dateType);
    }

    @ApiOperation("商家管理(我的收益可提现)")
    @PostMapping({"/findBySellerShopIncome"})
    public Result findBySellerShopIncome() {
        return this.sellerShopService.findBySellerShopIncome();
    }
}
